package com.nt.train.service.factory;

import com.nt.train.service.Shape;

/**
 * @author hlf
 * @version 1.0
 * @date 2022/8/5 18:20
 */
public class ShapeFactory {

    /**
     * 使用 getShape 方法获取几何图形类型的对象
     */
    public static Shape getShape(String shapeType) {
        if ("circle".equalsIgnoreCase(shapeType)) {
            return new Circle();
        } else if ("rectangle".equalsIgnoreCase(shapeType)) {
            return new Rectangle();
        } else if ("square".equalsIgnoreCase(shapeType)) {
            return new Square();
        }
        return null;
    }

    /**
     * 使用 getShape 方法获取几何图形类型的对象
     */
    public static Shape getShape2(String shapeType) {
        switch (shapeType){
            case "circle":
                return new Circle();
            case "rectangle":
                return new Rectangle();
            case "square":
                return new Square();
            default:
                return null;
        }
    }
}
